package com.linglingC.mapper;

import com.linglingC.pojo.Resident;
import com.linglingC.pojo.ResidentNameId;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ResidentMapper {

    @Select("select * from resident")
    List<Resident> findAll();

    @Options(useGeneratedKeys = true,keyProperty = "ID")
    @Insert("insert into resident( name, gender, telephone, room, checkin)" +
            " values (#{name},#{gender},#{telephone},#{room},#{checkin})")
    void addResident(Resident resident);


    List<Resident> selectP(Resident resident);

    @Update("update resident set name=#{name},gender=#{gender},telephone=#{telephone},room=#{room},checkin=#{checkin} " +
            "where ID=#{ID}")
    void editResident(Resident resident);

    @Delete("delete  from resident where ID= #{ID}")
    void deleteOneResident(Integer id);

    @Select("select ID,name from resident")
    List<ResidentNameId> findNameId();
}
